package com.winit.cloudlink.mgmt.task;

import org.springframework.data.cassandra.repository.Query;
import org.springframework.data.cassandra.repository.TypedIdCassandraRepository;

import java.util.List;

/**
 * 任务仓库
 */

public interface TaskRepository extends TypedIdCassandraRepository<TaskPO, String> {

    /**
     * 根据区域查询任务
     *
     * @param area 区域
     * @return
     */
    @Query("select * from " + TaskPO.TABLE_TASK + " where area = ?0")
    List<TaskPO> findByArea(String area);

    /**
     * 查询任务
     *
     * @param area 区域
     * @param name 名称
     * @return
     */
    @Query("select * from " + TaskPO.TABLE_TASK + " where area = ?0 and name = ?1 ALLOW FILTERING")
    TaskPO findByAreaAndName(String area, String name);
}
